<?php
error_reporting(0);
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require_once("include/config.php");
require_once("include/httpUtil.php");
require_once('config.php');

$phone = $_POST['phone'];
$shibie = $_POST['tui'];
$pwd = $_POST['pwd'];
$uid=time().rand(10,99);
$username='zsw-'.rand(1000,9999);

//注册写入表

	$sqli = "select * from tbl_user where userid = '".$phone."'";
	$queryi=mysql_query($sqli);
	$rowi=mysql_fetch_array($queryi);
	$sqlxx = "select * from tbl_dxt ";
	$queryxx=mysql_query($sqlxx);
	$rowxx=mysql_fetch_array($queryxx);
	if($rowi){
		
	$arr = array('error'=>1,'msg'=>'注册失败');
	echo json_encode($arr);
	exit;
	}
	
		
	$todata=date('Y-m-d H:i:s',strtotime("+12 months"));
	
	$sql="INSERT INTO tbl_user 
	 VALUES(
	'".$uid."',
	'http://www.goodshare.com.cn/upload/zu.png',
	'".$pwd."',
	0,
	0,
	'".date('Y-m-d H:i:s')."',
	'".$phone."',
	'".date("Y-m-d H:i:s")."',
	0,
	'".$username."',
	0,
	0,
	0,
	1,
	200,
	50,
	'".$_POST["tui"]."',
		1,
		0,'0','0','0','0','0',0,0,'".date('Y-m-d H:i:s')."','0.00'
	)";
	$uu=mysql_query($sql);
	//$a="insert into tbl_yhq values (0,'".$_POST["yhid"]."',1,2,0,0,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',0,0)";
	
	if($_POST["tui"]!=""){
	$j = "insert into tbl_zhangdan values (0,'邀请送积分','200',0,0,1,0,'".date('Y-m-d H:i:s')."','".$_POST["tui"]."',0,0,2)";
      mysql_query($j);	
	$jj = "insert into tbl_zhangdan values (0,'邀请送信用','50',0,0,1,0,'".date('Y-m-d H:i:s')."','".$_POST["tui"]."',0,0,1)";
      mysql_query($jj);	  
	}
    //		
	$b="insert into tbl_yhq values (0,'".$uid."',2,1,0,1,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',0,0)";
    $c="insert into tbl_yhq values (0,'".$uid."',3,1,0,1,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',0,0)";

	$bb="insert into tbl_yhq values (0,'".$uid."',10,1,0,1,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',0,0)";
    $cc="insert into tbl_yhq values (0,'".$uid."',20,1,0,1,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',0,0)";
	$dd="insert into tbl_yhq values (0,'".$uid."',25,1,0,1,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',0,0)";
//

	$ba="insert into tbl_yhq values (0,'".$uid."',2,1,0,2,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',151209639838,0)";
    $ca="insert into tbl_yhq values (0,'".$uid."',3,1,0,2,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',151209639838,0)";
	$bba="insert into tbl_yhq values (0,'".$uid."',10,1,0,2,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',151209639838,0)";
    $cca="insert into tbl_yhq values (0,'".$uid."',20,1,0,2,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',151209639838,0)";
	$dda="insert into tbl_yhq values (0,'".$uid."',25,1,0,2,0,1,'".date('Y-m-d')."','".date("Y-m-d", strtotime("+2 months"))."',151209639838,0)";	
	
	mysql_query($ba);
	mysql_query($ca);	
	mysql_query($bba);
	mysql_query($cca);
	mysql_query($dda);		
	
	

    $d="insert into tbl_hongbao values (0,'".$uid."',1,'".date('Y-m-d')."')";
	$e = "insert into tbl_zhangdan values (0,'注册送50信用','50',0,50,1,0,'".date('Y-m-d H:i:s')."','".$uid."',0,0,1)";	
	$g = "insert into tbl_zhangdan values (0,'注册送200积分','200',200,0,1,0,'".date('Y-m-d H:i:s')."','".$uid."',0,0,2)";		
	$f = "insert into tbl_tutu values (0,'".$username."','默认个性签名','没数据','没数据','".$uid."','".date('Y-m-d H:i:s')."','".$_POST["phone"]."','没数据','没数据','没数据',0,0,0,0)";
	//mysql_query($a);
	mysql_query($b);
	mysql_query($c);
    mysql_query($d);
	mysql_query($e);
	mysql_query($f);
	mysql_query($g);
	
	mysql_query($bb);
	mysql_query($cc);
	mysql_query($dd);	
	
	//短信发送开始--租方
	

//jies	
	if($uu){
		
	$shuyu=$username; 
	$shuyu1=mb_substr($shuyu,0,1,'utf8' );
	
$funAndOperate = "industrySMS/sendSMS";
// 生成body
$body = createBasicAuthData();
// 在基本认证参数的基础上添加短信内容和发送目标号码的参数
$body['smsContent'] = '【众晒网】亲爱的'.$shuyu1.'**用户,'.$rowxx["name"].',详情请见系统消息。';
$body['to'] = ''.$_POST["phone"].'';
$result = post($funAndOperate, $body);	


qy_close();
	$arr = array('error'=>0,'uid'=>$uid ,'msg'=>'注册失败');
	echo json_encode($arr);
	
		exit;
	}else{

	qy_close();
	$arr = array('error'=>1,'msg'=>'注册失败');
	echo json_encode($arr);
	}











?>
